package cc.sheji.controller;


import cc.sheji.Service.FileService;
import cc.sheji.domain.JsonResult;
import cc.sheji.exception.FileException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;


@RestController
@RequestMapping(value = "/api/v1/file")
public class FileController {

    @Autowired
    FileService fileService;

    @PostMapping("/upload")
    public JsonResult upload(MultipartFile file, HttpServletRequest req) throws FileException {
        return JsonResult.Success(fileService.upload(file, req));
    }

}
